package com.jbookshelf.dal.entities;

// Generated 23.11.2012 22:05:17 by Hibernate Tools 3.6.0

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * UsersPermissions generated by hbm2java
 */
@Entity
@Table(name = "USERS_PERMISSIONS", schema = "PUBLIC", catalog = "PUBLIC", uniqueConstraints = @UniqueConstraint(columnNames = {
		"USER_ID", "PERMISSION_ID" }))
public class UsersPermissions implements java.io.Serializable {

	private UsersPermissionsId id;
	private Users usersByUserId;
	private Users usersByGrantedBy;
	private Permissions permissions;

	public UsersPermissions() {
	}

	public UsersPermissions(UsersPermissionsId id, Users usersByUserId,
			Users usersByGrantedBy, Permissions permissions) {
		this.id = id;
		this.usersByUserId = usersByUserId;
		this.usersByGrantedBy = usersByGrantedBy;
		this.permissions = permissions;
	}

	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "userId", column = @Column(name = "USER_ID", nullable = false)),
			@AttributeOverride(name = "permissionId", column = @Column(name = "PERMISSION_ID", nullable = false)),
			@AttributeOverride(name = "grantedOn", column = @Column(name = "GRANTED_ON", nullable = false, length = 10)),
			@AttributeOverride(name = "grantedBy", column = @Column(name = "GRANTED_BY", nullable = false)) })
	public UsersPermissionsId getId() {
		return this.id;
	}

	public void setId(UsersPermissionsId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "USER_ID", nullable = false, insertable = false, updatable = false)
	public Users getUsersByUserId() {
		return this.usersByUserId;
	}

	public void setUsersByUserId(Users usersByUserId) {
		this.usersByUserId = usersByUserId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "GRANTED_BY", nullable = false, insertable = false, updatable = false)
	public Users getUsersByGrantedBy() {
		return this.usersByGrantedBy;
	}

	public void setUsersByGrantedBy(Users usersByGrantedBy) {
		this.usersByGrantedBy = usersByGrantedBy;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PERMISSION_ID", nullable = false, insertable = false, updatable = false)
	public Permissions getPermissions() {
		return this.permissions;
	}

	public void setPermissions(Permissions permissions) {
		this.permissions = permissions;
	}

}
